<%@tag pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="consignum" tagdir="/WEB-INF/tags"%>
<%@attribute name="id"%>
<%@attribute name="styleClass"%>
<%@attribute name="style"%>
<%@attribute name="icon"%>
<%@attribute name="title"%>
<%@attribute name="tooltip"%>
<%@attribute name="alertConfirmation"%>
<%@attribute name="messageConfirmation"%>
<%@attribute name="titleConfirmation"%>
<%@attribute name="tooltipDirection"%>
<%@attribute name="loading" type="java.lang.Object"%>
<%@attribute name="rendered" type="java.lang.Boolean"%>
<%@attribute name="execute" required="true"%>
<%@attribute name="update" required="true"%>
<%@attribute name="action" required="true"%>
<%@attribute name="conversation"%>
<%@attribute name="value" type="java.lang.Object"%>
<c:if test="${empty rendered or rendered eq true}" >
		
		 <c:if test="${not empty conversation}">
	     	<c:set var="actioCustom" value="${action}?cid=${conversation}" />
	 	 </c:if>
	 	 <c:if test="${empty conversation}">
	     	<c:set var="actioCustom" value="${action}" />
	 	 </c:if>
		<a
		<c:if test="${empty alertConfirmation or alertConfirmation eq false}">
		 	href="javascript:void(0);"
		  	onclick="javascript: submitAjax('${execute}','${actioCustom}','${update}','${loading}');" 
		 </c:if>
		 <c:if test="${not empty alertConfirmation and alertConfirmation eq true}">
		 	href="#"
		 </c:if>
		<consignum:renderedField field="id" value="${id}" />
		<consignum:renderedField field="name" value="${id}" />
		<consignum:renderedField field="class" value="${styleClass}" /> 
		
		<c:if test="${not empty tooltip}">
			<consignum:renderedField field="rel" value="tooltip" />
			<consignum:renderedField field="data-placement" value="${tooltipDirection}" defaultValue="top" />
			<consignum:renderedField field="data-original-title" value="${tooltip}" />
			<consignum:renderedField field="lang" value="tooltip" />
		</c:if>
		<consignum:renderedField field="value" value="${value}" /> 
		<consignum:renderedField field="style" value="${style}" /> > 
	<i class="<c:out value="${icon}" default=" " />"> </i> <c:out
			value="${value}" />
 </a>
</c:if>
<c:if test="${not empty id}">
	<c:if test="${empty alertConfirmation or alertConfirmation eq true}">
		<script>
			$(document).ready(function() {
					$.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
						_title : function(title) {
							if (!this.options.title) {
								title.html("&#160;");
							} else {
								title.html(this.options.title);
							}
						}
					}));
				
					// Dialog click
					$('#${id}').click(function() {
						$('#dialogGeneric${id}').dialog('open');
						return false;
				
					});
				
					$('#dialogGeneric${id}').dialog({
						autoOpen : false,
						width : 600,
						resizable : false,
						modal : true,
						title : "<div class='widget-header'><h4><i class='fa fa-warning'></i>${titleConfirmation}</h4></div>",
						buttons : [{
							html : "<i class='${icon}'></i>&nbsp; Confirmar",
							"id" : "idButtonConfirmar",
							"class" : "btn btn-danger",
							click : function() {
								$("#dialogGeneric${id} >").attr("disabled", "disabled");
								submitAjax('${execute}','${actioCustom}','${update}','${loading}');
								$(this).dialog("close");
							}
						}, {
							html : "<i class='fa fa-times'></i>&nbsp; Cancelar",
							"class" : "btn btn-default",
							"id" : "idButtonCancelar",
							click : function() {
								$(this).dialog("close");
							}
						}]
					});
				});
			</script>
			
		<div id="dialogGeneric${id}">
			<p><c:out value="${messageConfirmation}" default=" " /></p>
		</div>
	</c:if>
</c:if>
